<?php
/**
* This file holds a class for Bootstrap class.
* @package busmap
*/

/**
* Bootstrap class will be used to initialize several functions needed on the whole page.
* This class has _init* functions that will be called before anything else.
* @package busmap
*/
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

	/**
	* This function initializes the router with configuration from the routers.ini file.
	*/
	public function _initRouter()
	{	
		
		$frontController = Zend_Controller_Front::getInstance();
		$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/routers.ini');
		$router = $frontController->getRouter();
		$router->addConfig($config,'routes');

	}

	/**
	* This function initializes the HTML Doctype for the page.
	* Output will be called in layout.phtml file before anything else.
	*/
    protected function _initDoctype(){
        $this->bootstrap('view');
        $view = $this->getResource('view');
        $view->doctype('XHTML1_TRANSITIONAL');

    }

	/**
	* This function initializes the navigation.
	* It sets the structure of the pages in the site.
	*/
	public function _initNavigation(){
		$this->bootstrap('view');
		$this->bootstrap('layout');

		$overallLinks = array(

			array(
				'label'=>'Bussikaart',
				'controller'=>'index',
				'action'=>'index',
				'route'=>'default',
				'pages'=>array(
							array(
								'controller'=>'busstop',
								'label'=>'Peatused',
								'action'=>'index',
								'route'=>'default',
								'pages' => array(
										array( //Troublesome entry
											'label'=>'Peatus',
											'route'=>'busstop',
											'controller'=>'busstop',
											'action'=>'oneBusstop',
											'busstopName'=>'asd',
											'params' => array('busstopName', 'er'),
											'visible' => 0,
										)
									)
							),
							array( 
								'controller'=>'busline',
								'label'=>'Liinid',
								'module'=>'default',
								'action'=>'index',
								'route'=>'default' 
							)		
						)
			),
			array(
				'label'=>'Administratsioon',
				'controller'=>'admin',
				'action'=>'index',
				'route'=>'default',
				'pages'=>array(
							array(
								'controller'=>'admin',
								'action'=>'editBusstops',
								'label'=>'Peatused',
								'route'=>'default'
							),
							array( 
								'controller'=>'admin',
								'action'=>'editBuslines',
								'label'=>'Liinid', 
								'route'=>'default'
							),
							array( 
								'controller'=>'admin',
								'action'=>'editColors',
								'label'=>'Värvid',
								'route'=>'default'
							),
							array( 
								'controller'=>'admin',
								'action'=>'editUsers',
								'label'=>'Kasutajad',
								'route'=>'default'
							)				
						)
			)
		);

		$nav = new Zend_Navigation($overallLinks);
		$this->getResource('layout')->getView()->navigation($nav);

	}

}

